<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <jsp:include page="../base_head.jsp"></jsp:include>
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form" id="bill_form"
                action="" method="post">
                	<c:if test="${bill_info!=null}">
                	<input type="hidden" id="" name="bill_id" value="${bill_info.bill_id}">
                	</c:if>
                	
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>用户id
                        </label> 
                        <div class="layui-input-inline">
                            <input type="text" id="" name="user_id" required autocomplete="off" class="layui-input"
                             value="${bill_info.user_id}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>类型
                        </label>
                         <div class="layui-input-inline">
                        	<select name="type_id">
	                           	<c:forEach var="typeinfo" items="${type_list}">
	                           		<option value="${typeinfo.type_id}" 
	                           		${typeinfo.type_id==bill_info.type_id?"selected":""}
	                           		>${typeinfo.type_name}${typeinfo.type_type==0?"(支出)":"(收入)"}</option>
	                           	</c:forEach>
                           </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>金额
                        </label>
                         <div class="layui-input-inline">
                            <input type="text" id="" name="amount" required autocomplete="off" class="layui-input"
                             value="${bill_info.amount}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>创建时间
                        </label>
                         <div class="layui-input-inline">
                            <input type="text" id="create_time" name="create_time" required="" autocomplete="off" class="layui-input"
                             value="${bill_info.create_time}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label">
                             	备注
                        </label>
                         <div class="layui-input-inline">
                            <input type="text" id="" name="remark" autocomplete="off" class="layui-input"
                             value="${bill_info.remark}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_repass" class="layui-form-label"></label>
                        <button type="button" class="layui-btn" lay-filter="add" lay-submit="">确认</button>
                    </div>
                </form>
            </div>
        </div>
        <script src="${proname}/js/jquery.min.js"></script>
        <script>
	        layui.use(['form','laydate'], function(){
	        	  var laydate = layui.laydate;
	        	  var form = layui.form;
	        	  $ = layui.jquery;
	        	  
	        	//执行一个laydate实例
	      		laydate.render({
	      			elem : '#create_time' //指定元素
	      		});
	        	
	      		form.on('submit(add)',
   		        function(data) {
   		            var dataset = data.field;
   		            console.log(dataset);
   		            
   		            $.post("${proname}/bill/"+("${bill_info!=null?'1':''}"?"edit.do":"add.do"),
            		{
            			bill_info: JSON.stringify(dataset),
            		},
   		            function(res){
   		            	if(res=="1"){
   		            		layer.alert("操作成功", {
   		                        icon: 1
   		                    },function(){parent.location.reload()});
   		            	}else{
   		            		alert("操作失败");
   		            	}
   		            });
   		            return false;
   		        });
	        	  
	        });
	        
	        
	     
        </script>
       
    </body>

</html>